#include<iostream>
using namespace std;

#define max(a,b) (a>b?a:b)
#define min(a,b) (a<b?a:b)

template <typename T>
T maxn(const T a[]);

template <typename T>
T maxn(T a[], int size);

template<typename T>
void show_arr(const T a[]);

template<typename T>
void show_arr(const T a[], int size);

void main()
{
	int test_int[6] = { 1, 2, 4, 8, 16, 32 };
	double test_dbl[4] = { 1.0, 2.0, 4.0, 8.0 };
	cout << "test for int array : ";
	show_arr(test_int);
	cout << "test for double array : " ;
	show_arr(test_dbl);

	cout << "the max int of test_int array is " <<maxn(test_int, 6) << endl;
	cout << "the max double of test_dbl array is " <<  maxn(test_dbl, 4) << endl;

	system("pause");
}

template <typename T>
T maxn(const T a[])
{
    int size = sizeof(a) / a[0];
    maxn(a, size);
}

template <typename T>
T maxn(T a[], int i)
{
	T max = a[0];
	for (int j = 0, jc = min(j,i); j < jc; j++)
		max = (a[j] > max) ? a[j] : max;
	return max;
}

template<typename T>
void show_arr(const T a[])
{
    int size = sizeof(a) / a[0];
    show_arr(a, size);
}

template <typename T>
void show_arr(const T a[],int i)
{
	for (int j = 0, jc = min(j,i); j < jc; j++)
		cout << a[j]<<" ";
	cout << endl;
}
